﻿Public Class Site

    Inherits System.Web.UI.MasterPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Select Case UserRole()
            Case -1
                NavigationMenu.Visible = False
            
        End Select
    End Sub

    Public Function ReturnMisiuneID() As Integer

        Dim misIDadapter As New eServicii.DataSetJURAMANTTableAdapters.aspnet_UsersTableAdapter
        Dim MisiuneID As Integer
        Dim NumeUser As String
        If HttpContext.Current.Request.IsAuthenticated Then
            NumeUser = Membership.GetUser().UserName()
            NumeUser = HttpContext.Current.User.Identity.Name
            MisiuneID = misIDadapter.GetDataMisID(NumeUser).Rows(0).Item("MisiuneID")
            Return MisiuneID
        Else
            Return 0
        End If
    End Function

    Public Function UserRole() As Integer
        If HttpContext.Current.Request.IsAuthenticated Then
            If Context.User.IsInRole("Administrator") Then
                Return 0
            Else
                If Context.User.IsInRole("User") Then
                    Return 1
                Else
                    Return 2
                End If
            End If
        Else
            Return -1
        End If
    End Function
End Class